using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
    /// <summary>
    /// Controller class for tblSearchAll
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class TblSearchAllController
    {
        // Preload our schema..
        TblSearchAll thisSchemaLoad = new TblSearchAll();
        private string userName = string.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}

					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}

				}

				return userName;
            }

        }

        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public TblSearchAllCollection FetchAll()
        {
            TblSearchAllCollection coll = new TblSearchAllCollection();
            Query qry = new Query(TblSearchAll.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }

        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public TblSearchAllCollection FetchByID(object Id)
        {
            TblSearchAllCollection coll = new TblSearchAllCollection().Where("ID", Id).Load();
            return coll;
        }

		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public TblSearchAllCollection FetchByQuery(Query qry)
        {
            TblSearchAllCollection coll = new TblSearchAllCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }

        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object Id)
        {
            return (TblSearchAll.Delete(Id) == 1);
        }

        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object Id)
        {
            return (TblSearchAll.Destroy(Id) == 1);
        }

        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(int SiteUserID,string MediaType,string TVChannels,string RadioChannels,string CableChannels,string PressMedia,string InternetMedia,string Sector,string SubSector,string Category,string Advertiser,string Agency,string Product,bool? Iscategory,bool? IsProduct,bool? IsAdvertiser,string Layout,string SDate,string EDate,string Days)
	    {
		    TblSearchAll item = new TblSearchAll();
		    
            item.SiteUserID = SiteUserID;
            
            item.MediaType = MediaType;
            
            item.TVChannels = TVChannels;
            
            item.RadioChannels = RadioChannels;
            
            item.CableChannels = CableChannels;
            
            item.PressMedia = PressMedia;
            
            item.InternetMedia = InternetMedia;
            
            item.Sector = Sector;
            
            item.SubSector = SubSector;
            
            item.Category = Category;
            
            item.Advertiser = Advertiser;
            
            item.Agency = Agency;
            
            item.Product = Product;
            
            item.Iscategory = Iscategory;
            
            item.IsProduct = IsProduct;
            
            item.IsAdvertiser = IsAdvertiser;
            
            item.Layout = Layout;
            
            item.SDate = SDate;
            
            item.EDate = EDate;
            
            item.Days = Days;
            
	    
		    item.Save(UserName);
	    }

    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(int Id,int SiteUserID,string MediaType,string TVChannels,string RadioChannels,string CableChannels,string PressMedia,string InternetMedia,string Sector,string SubSector,string Category,string Advertiser,string Agency,string Product,bool? Iscategory,bool? IsProduct,bool? IsAdvertiser,string Layout,string SDate,string EDate,string Days)
	    {
		    TblSearchAll item = new TblSearchAll();
		    
				item.Id = Id;
				
				item.SiteUserID = SiteUserID;
				
				item.MediaType = MediaType;
				
				item.TVChannels = TVChannels;
				
				item.RadioChannels = RadioChannels;
				
				item.CableChannels = CableChannels;
				
				item.PressMedia = PressMedia;
				
				item.InternetMedia = InternetMedia;
				
				item.Sector = Sector;
				
				item.SubSector = SubSector;
				
				item.Category = Category;
				
				item.Advertiser = Advertiser;
				
				item.Agency = Agency;
				
				item.Product = Product;
				
				item.Iscategory = Iscategory;
				
				item.IsProduct = IsProduct;
				
				item.IsAdvertiser = IsAdvertiser;
				
				item.Layout = Layout;
				
				item.SDate = SDate;
				
				item.EDate = EDate;
				
				item.Days = Days;
				
		    item.MarkOld();
		    item.Save(UserName);
	    }

    }

}

